#ifndef BATTLEENTITY_H_
#define BATTLEENTITY_H_

#include "battlestats.h"
#include "entity.h"
#include "material.h"
#include <vector>

class CBattleEntity : public CEntity
{

private:

	CBattleAttackData * m_pBattleAttackData;
	CBattleCharacterData * m_pBattleCharacterData;
	
	int m_Health, m_MaxHealth;
	float m_ActionMeter;
	
	bool m_bBeingAttacked;

public:
	
	CBattleEntity() : CEntity(), m_pBattleAttackData( NULL ), m_ActionMeter( 0 )
	{
		
		m_bBeingAttacked = false;
		
	}
	
	inline void SetBeingAttacked( bool b )
	{
		
		m_bBeingAttacked = b;
		
	}
	
	inline bool BeingAttacked()
	{
	
		return m_bBeingAttacked;
		
	}
	
	inline int GetActionMeter()
	{
		
		return m_ActionMeter;
		
	}
	
	inline void SetActionMeter( float i )
	{
		
		m_ActionMeter = i;
		
	}
	
	inline void IncrementActionMeter()
	{
		
		m_ActionMeter += m_pBattleCharacterData->GetSpeed() * m_pEntityInterface->GetDPS();
		
		if( m_ActionMeter > 100.0f ) 
			m_ActionMeter = 100.0f;
		
	}
	
	inline bool ActionMeterFull()
	{
		
		return ( m_ActionMeter >= 100.0f );
		
	}
	
	inline void SetCurAttack( CBattleAttackData * ad )
	{
		
		m_pBattleAttackData = ad;
		
	}
	
	inline CBattleAttackData * GetCurAttack()
	{
		
		return m_pBattleAttackData;
		
	}
	
	inline bool IsDoingAttack()
	{
		
		return ( m_pBattleAttackData != NULL );
		
	}
	
	inline CBattleCharacterData * GetBattleData()
	{
		
		return m_pBattleCharacterData;
		
	}
	
	void BindBattleStats();
	
	inline void SetBattleStats( CBattleCharacterData * s )
	{
		
		m_pBattleCharacterData = s;
		
	}

	inline const std::string & GetNiceName() 
	{
		
		return m_pBattleCharacterData->GetNiceName();
		
	}
	
	inline void Damage( int d )
	{
		
		m_Health -= d;
		
	}
	
	inline float GetHealthPercent()
	{
		
		return ( float )m_Health / ( float )m_MaxHealth;
		
	}
	
	inline int GetHealth()
	{
		
		return m_Health;
		
	}
	
	inline int GetMaxHealth()
	{
		
		return m_MaxHealth;
		
	}
	
	void Think();

};



class CQueuedBattleAttack
{
	
private:
	
	CBattleAttackData * m_pAttack;
	CBattleEntity * m_pRec, * m_pParent;
	
public:
	
	CQueuedBattleAttack( CBattleEntity * parent, CBattleEntity * rec, CBattleAttackData * ad ) :  m_pAttack( ad ), m_pRec( rec ), m_pParent( parent )
	{
		
		
		
	}
	
	inline CBattleEntity * GetVictim()
	{
		
		return m_pRec;
		
	}
	
	inline CBattleEntity * GetAttacker()
	{
	
		
		return m_pParent;
	}
	
	
	inline CBattleAttackData * GetAttack()
	{
		
		return m_pAttack;
		
	}
};

#endif
